package io.mft.flow.core.executable;

import io.mft.commons.function.ExecuteReturn;
import io.mft.flow.core.executable.drive.ChainConditionDriver;
import io.mft.flow.data.ChainContext;
import lombok.Getter;
import lombok.Setter;

//@Builder
@Getter
@Setter
/**
 * 流程节点链式结构
 * @说明：TODO
 * @类型名称：ChainCondition
 * @创建者: 胡常建  
 * @创建时间: 2021年3月4日 上午8:41:49
 * @修改者: 胡常建  
 * @修改时间: 2021年3月4日 上午8:41:49
 */
public class ChainCondition implements Executable {
	private ChainConditionDriver chainConditionDriver;
	private Condition condition;
	private ChainCondition nextChainCondition;
	private Chain chain;
	private String previousJoinUniqueId="";
	private String nextJoinUniqueId="";

	public ChainCondition(Condition condition) {
		this.condition=condition;
		this.condition.setChainCondition(this);
	}
	@Override
	public ExecuteReturn execute(ChainContext context) throws Exception {
		return condition.execute(context);
	}
	@Override
	public ExecutableType getType() {
		return ExecutableType.CHAIN;
	}

	@Override
	public String getId() {
		return previousJoinUniqueId+"-"+nextJoinUniqueId;
	}
	
	public String note() {
		return condition.last().getUniqueId();
	}
	
}
